package se.webbzon.oschi01.nanotimer;

/**
 * A timer to measure time difference (in nanoseconds) 
 * 
 * @author Oscar Hinrichsen (oschi01)
 */
public class NanoTimer {

	// The creation time of this instance
	private long time;
	
	/*============================================================
	Constructors
	============================================================*/
	
	/** Creates a new timer. **/
	public NanoTimer() {};
	
	/*============================================================
	Public Methods
	============================================================*/
	
	/** Starts the nano timer **/
	public void start() {
		time = System.nanoTime();
	}
	
	/** Returns the time difference (in nanoseconds) between
	 *  the creation of the timer and the current time. */
	public long duration() {
		return System.nanoTime() - time;
	}
	
}
